package com.everspring.mapstruct.use.mapping;

import com.everspring.mapstruct.use.model.Order;
import com.everspring.mapstruct.use.model.OrderVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * Date： 2020/9/15 15:52
 *
 * @author changchun.xue
 */
@Mapper(uses = {OrderDetailMapping.class, StatusEnumTransUtil.class})
public interface OrderMapping {
    OrderMapping INSTANCE = Mappers.getMapper(OrderMapping.class);

    @Mappings({
            @Mapping(source = "id",target = "orderId"),
            @Mapping(source = "price",target = "buyPrice"),
            @Mapping(source = "productName",target = "spuName"),
            @Mapping(source = "status",target = "statusEnum"),
            @Mapping(source = "orderDate",target = "orderDate",dateFormat = "dd-MM-yyyy HH:mm:ss"),
            @Mapping(source = "orderDetailList",target = "orderDetailVoList"),
    })
    OrderVo toVo(Order order);

    Order toEntity(OrderVo orderVo);
}
